package com.sinosoft.gateway.xuzhou;

import org.apache.commons.lang.StringUtils;

import com.sinosoft.gateway.tcp.client.TcpClient;

public class XuzhouClient {
	public static String send(String host, int port, String transCode, String packet) throws Exception {
		TcpClient client = getTcpClient(transCode);
		String response = client.call(host, port, packet);
		return response;
	}

	public static TcpClient getTcpClient(String transCode) {
		TcpClient client = new TcpClient();
		client.setEncoding("GBK");
		client.setHeadBeforeLength("");
		client.setHeadAfterLength(StringUtils.rightPad(transCode, 7) + "gs0007");
		client.setLengthHeadSize(6);
		client.setLengthHeadPad(TcpClient.PAD_RIGHT);
		client.setLengthHeadPadChar(" ");
		return client;
	}
}
